#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import json

sys.path.append(
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "qtrade")
)

import requests

# 测试
base_url = "http://localhost:8000/backtest/"

headers = {
}


def test_income_times():
    url = base_url + "income_times_run"
    data = dict(
            strategy_name = "MACD金叉",
            # strategy_name = "KDJ小于0最小J值",
            from_date = 20211101,
            low_price = 10,
            high_price = 15,
            days = 10,
            percent = 3
        )
    res = requests.get(url, params=data)
    content = json.loads(res.content)
    print(content)


def test_delete():
    url = base_url + str("3")
    res = requests.delete(url)
    content = json.loads(res.content)
    print(content)


def test_get():
    url = base_url + str("1")
    res = requests.get(url)
    content = json.loads(res.content)
    print(content)


def test_backtest_record():
    url = base_url + str("2/record")
    res = requests.get(url)
    content = json.loads(res.content)
    print(content)
